/*
 * @Author: yanyqf
 * @Date: 2020-03-10 14:08:22
 * @LastEditTime: 2020-03-26 14:57:14
 * @Description: file content
 */
import { vendorsGetTId } from 'utils/config.js';
let tenantId;
let cookieStr = document.cookie.split(';').find(cur => cur.indexOf('tenantid=') != -1)
if(cookieStr){
     tenantId = cookieStr.split('=')[1];
}
export const searchTpl = {
    name: '查询模板',
    col: 4,
    dataSource: 'projectIndicators_search_area',
    items: [
        {
            itemtype: "refer",
            refType: 'tree',
            refPk: 'pkSrc',
            refPk1: 'pkTenant',
            label: "项目组织",
            initialvalue: { value: "00015E10000000002XX6", display: "幸福总公司", scale: -1 },
            isMultiSelectedEnabled: false,
            required: true,
            selectShowKey: 'sname',
            reqRef: {
                queryCondition: function () {
                   
                    return { pkTenant: tenantId}
                },
                method:'get',
                refUrl: "/organization/getPermOrgByUser",
            },
        },
        {
            itemtype: "refer",
            refType: 'grid',
            refPk: 'pkProject',
            label: "项目",
            initialvalue: { value: "00015E10000000002XX6", display: "幸福总公司", scale: -1 },
            isMultiSelectedEnabled: false,
            required: true,
            selectShowKey: 'sname',
            reqRef: {
                queryCondition: function () {
                    let org = this.search.getSearchValue({ refPk: 'pkSrc', requireKey: ['pkSrc', 'pkTenant']});
                    return {
                        pkOrg: org.length ? org[0] : null
                    }
                },
                method:'get',
                refUrl: "/project/queryProjectsByOrgExt",
                setCoByKey:[
                    { name: '项目编码', key: 'scode' },
                    { name: '项目名称', key: 'sname'},
                ],
            },
        },
        {
            itemtype: "refer",
            refType: 'grid',
            refPk: 'pkMeasureindex',
            label: "指标名称",
            initialvalue: { value: "00015E10000000002XX6", display: "幸福总公司", scale: -1 },
            isMultiSelectedEnabled: true,
            required: false,
            selectShowKey: 'name',
            reqRef: {
                queryCondition: function () {
                    // let org = this.prop.serach.getValue('pkOrg')
                    let projectId = this.search.getSearchValue({ refPk: 'pkProject', requireKey: 'pkProject'});
                    return {
                        projectId: projectId.length? projectId[0] : ''
                    }
                },
                method:'get',
                refUrl: "/measureIndex/queryByProjectIdAndOrg",
                setCoByKey:[
                    { name: '指标编码', key: 'code' },
                    { name: '指标名称', key: 'name'},
                ]
            },
        },
        {
            itemtype: "refer",
            refType: 'grid',
            refPk: 'pkSchedule',
            label: "来源计划名称",
            initialvalue: { value: "00015E10000000002XX6", display: "幸福总公司", scale: -1 },
            isMultiSelectedEnabled: true,
            required: false,
            selectShowKey: 'name',
            reqRef: {
                queryCondition: function () {
                    let projectId = this.search.getSearchValue({ refPk: 'pkProject', requireKey: 'pkProject'});
                    return {
                        pkProject: projectId.length? projectId[0] : ''
                    }
                },
                method:'get',
                refUrl: "/schedule/queryByProjectId",
                setCoByKey:[
                    { name: '计划名称', key: 'name'},
                ]
            },
        },
        {
            itemtype: "section-date",
            refPk: 'sectionDate',
            label: "起止日期",
            initialvalue: { value: "00015E10000000002XX6", display: "幸福总公司", scale: -1 },
            isMultiSelectedEnabled: true,
            queryCondition: () => {
                return {}
            },
            refUrl: "uapbd/refer/org/ItemOrgDefaultTreeRef/index",
            required: false,
        }
    ]
}